<include file="Public/head" xmlns="http://www.w3.org/1999/html"/>
<include file="Public/common_header" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/css/cashier.css" />
<div class="mian">
    <include file="Public/sidebar" menu="hdgl.qccrkq"  />
    <div class="mianR">
		<div class="yuyue">
			<ul>
				<li onclick="getList(1);" data-id="0" class="yuCurrent">待发放</li>
                <li onclick="getList(2);" data-id="1">已发放</li>
                <li onclick="getList(3);" data-id="1">已达标待发券</li>
			</ul>
		</div>
		<form id="searchFrom">
            <div class="yuSuo clearfix">
                <div id="search1">
                    <input type="text" class="suoDian" id="code" placeholder="请输入卡券口令号" value="">
                </div>
                <div id="search2" style="display:none;">
                    <input type="text" class="suoDian" id="user_id" placeholder="请输入发放用户ID" value="">
                    <input type="text" class="suoDian" id="mobile" placeholder="请输入发放用户手机号" value="">
                </div>
                <div id="search3" style="display:none;">
                    <input readonly type="text" id="start" name="start_time" placeholder="发放开始时间"/>
                    <em></em>
                    <input readonly type="text" id="end" name="end_time" placeholder="发放结束时间"/>
                </div>
                <div id="search4">
                    <input type="button" onclick="searchList();" value="搜索" class="suoSou">
                    <input type="button" onclick="getData(1);" value="全部" class="suoSou">
                </div>
                <div id="search5">
                    <input type="button" onclick="sendCode();" value="发券" class="suoSou">
                </div>
            </div>
        </form>
		<div class="listBox" id="listBox">
			<div class="yuList">
			</div>
		</div>
		<div class="clear"></div>
	</div>
</div>

<script>
var status = 1;
var pages = 1;
getData(1);

function getData(page,params){
    if(status == 2){
        $('#search1').hide();
        $('#search1 input').val('');
        $('#search2').show();
        $('#search3').show();
        $('#search5').hide();
    }else if(status == 3){
        $('#search1').hide();
        $('#search1 input').val('');
        $('#search2').show();
        $('#search3').hide();
        $('#search3 input').val('');
        $('#search5').show();
    }else{
        $('#search1').show();
        $('#search2').hide();
        $('#search2 input').val('');
        $('#search3').hide();
        $('#search3 input').val('');
        $('#search5').hide();
    }

	if(!params){
		params = {};
	}
	params.p = page;
    pages = page;
	params.status = status;
	$('.yuList').html('');
	$.post('/Active/getCode',params, function(data){
		$('.yuList').html(data);
	});
}
function getList(s){
	status = s;
	getData(1);
}

function get_page(page){
	getData(page);
}

function searchList(){
	var data = {
		'code' : $('#code').val(),
        'user_id' : $('#user_id').val(),
        'mobile' : $('#mobile').val(),
        'start' : $('#start').val(),
        'end' : $('#end').val()
	};
	getData(1, data);
}
$("#start").ymdateplugin({
    showTimePanel: true,
    changeMonth: true,
    changeYear: true
});

$("#end").ymdateplugin({
    showTimePanel: true,
    changeMonth: true,
    changeYear: true
});
function sendCode(){
    if(confirm('确定发放奖券吗?')){
        $.post('/Active/sendCode', function(data){
            if(data.code == 200){
                alert('发券完成,请等待发券执行!');
            }else{
                alert(data.msg);
            }
        },'json');
    }
}

</script>
<include file="Public/foot" />